<?php
use application\Comm\Func;
$img_path = Func::getImageCdnRand();
$lable = isset($lable)?$lable:'图片';
$dir_id = isset($dir_id)?$dir_id:2;
$iswater = isset($iswater)?$iswater:0;
?>
<script type="text/javascript">
    function doc_upload_success_many(file, data) {
        var json = $.parseJSON(data)

        $(this).bjuiajax('ajaxDone', json)
        if (json[BJUI.keys.statusCode] == BJUI.statusCode.ok) {
            $('#pic_show_many').append('<div class="item"> <div class="info"><span class="up_cancel" title="取消上传"><i class="fa fa-times-circle-o"></i></span></div> <div class="preview"> <span class="img"> <img src="<?php echo $img_path;?>' + json.filename + '"> </span> </div><div style="margin-top:5px"><input class="form-control" type="text" name="info[titles][]" value="" style="width:100px" /></div> ')
            $('#pic_show_many').append('<input type="hidden" name="info[images][]" value="' + json.filename + '" /></div>')
            $('.up_cancel').click(function(){
                $(this).parent().parent().remove();
            });
        }
    }
</script>
<tr>
    <td colspan="2">
        <label class="control-label x100"><?php echo $lable?>：</label>
        <div style="display:inline-block; vertical-align:top;">
            <div id="doc_pic_up" data-toggle="upload" data-uploader="<?php echo Func::createUrl('site/upload',['iswater'=>$iswater,'d'=>$dir_id])?>"
                 data-file-size-limit="1024000000"
                 data-file-type-exts="*.jpg;*.png;*.gif;*.mpg"
                 data-multi="true"
                 data-auto="true"
                 data-previewImg="true"
                 data-on-upload-success="doc_upload_success_many"
                 data-icon="cloud-upload"></div>
        </div>

    </td>
</tr>
<tr>
    <td colspan="2">
        <div style="display:inline-block; vertical-align:top;">
            <div class="bjui-upload">
                <div class="queue" style="display: block;" id="pic_show_many">
                    <?php

                        if(isset($info) && !empty($info)){
                        foreach($info as $k => $v){
                    ?>
                        <div class="item">
                            <div class="preview">
                            <span class="img"><img src="<?php echo $img_path.$v['src']?>"> </span>

                                <input type="hidden" name="info[images][]" value="<?php echo $v['src']?>" />
                            </div>
                            <span class="img"><input size="10" type="text" name="info[title][]" value="<?php echo $v['name']?>" /> </span>
                        </div>
                    <?php }}?>
                </div>

            </div>
        </div>

    </td>
</tr>